package com.foreknow.elmboot.service.impl;



import com.foreknow.elmboot.mapper.CartMapper;
import com.foreknow.elmboot.po.Cart;
import com.foreknow.elmboot.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CartServiceImpl implements CartService {
    @Autowired
    private CartMapper cartMapper;

    @Override
    public int saveCart(Cart cart) {
        int i = 0;
        try {
            i = cartMapper.saveCart(cart);
            return i;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public int updateCart(Cart cart) {
        int i = 0;
        try {
            i = cartMapper.updateCart(cart);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return i;

    }

    @Override
    public List<Cart> listCart(Cart cart) {

        try {
            List<Cart> carts = cartMapper.listCart(cart);
            return carts;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public int deleteCart(Cart cart) {
        int i = 0;
        try {
            i = cartMapper.deleteCart(cart);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return i;
    }
}
